package lagou.cn.homework

object Test01 {

  /**
   * @param cap 瓶盖数
   * @param empty 空瓶数
   * @param bottle 啤酒数
   * @return
   */
  def buyWine(cap:Int, empty:Int, bottle:Int):Int = {

    if (cap < 5 && empty < 3) {
      return bottle
    }

    val num1 = cap / 5
    val num2 = cap % 5
    val num3 = empty / 3
    val num4 = empty % 3

    buyWine(num1 + num3 + num2, num1 + num3 + num4, num1 + num3 + bottle)
  }

  def main(args: Array[String]): Unit = {

    val num = 100 / 2
    val numWine = buyWine(50, 50, 0)
    println(s"可以购买的啤酒数量为:${num + numWine}")
  }
}
